package com.fafa.swing.base;

import javax.swing.*;
import java.awt.*;

/**
 * @author : fafa
 * @version V1.0
 * @Project: SwingTest
 * @Package com.fafa.swing
 * @Description: GridLayoutDemo
 * @date Date : 2019年11月23日 11:27
 */
public class GridLayoutDemo extends JFrame {
    public static void main(String[] args) {
        JFrame jFrame = new JFrame("GridLayout布局计算器");
        JPanel jPanel = new JPanel();
        //指定面板的布局为GridLayout，4row4column,gap is 5
        jPanel.setLayout(new GridLayout(4,4,5,5));
        jPanel.add(new JButton("7"));
        jPanel.add(new JButton("8"));
        jPanel.add(new JButton("9"));
        jPanel.add(new JButton("/"));
        jPanel.add(new JButton("4"));
        jPanel.add(new JButton("5"));
        jPanel.add(new JButton("6"));
        jPanel.add(new JButton("*"));
        jPanel.add(new JButton("1"));
        jPanel.add(new JButton("2"));
        jPanel.add(new JButton("3"));
        jPanel.add(new JButton("-"));
        jPanel.add(new JButton("0"));
        jPanel.add(new JButton("."));
        jPanel.add(new JButton("="));
        jPanel.add(new JButton("+"));
        jFrame.add(jPanel);
        jFrame.setBounds(300,200,200,150);
        jFrame.setVisible(true);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
}
